﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace footwear
{
    public partial class ManagePoster : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (DbConnect.Connection == null)
            {
                var dbConnect = new DbConnect();
            }
            if (Request.QueryString["action"] != null && Request.QueryString["action"] != "")
            {
                var posterAdsBus = new PosterAdsBus();
                var item = posterAdsBus.GetAdsById(Request.QueryString["id"]);
                if (!Page.IsPostBack)
                {
                    txtId.Text = item.Id;
                    txtTitle.Text = item.Title;
                    txtDescription.Text = item.Description;
                    txtImageLink.Text = item.ImageSource;    
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtId.Text))
            {
                var posterAdsBus = new PosterAdsBus();
                posterAdsBus.UpdateAdsById(txtId.Text, txtTitle.Text, txtDescription.Text, txtImageLink.Text);
                txtId.Text = "";
                txtTitle.Text = "";
                txtDescription.Text = "";
                txtImageLink.Text = "";
            }
        }
    }
}